// The only global object for this extension.
var AccessibilityExtension = {};

// Basic namespace implementation.
(function() {

var namespaces = [];

// Namespace registration
this.ns = function(fn) {
    var ns = {};
    namespaces.push(fn, ns);
    return ns;
};

// Namespace initialization
this.initialize = function() {
    for (var i=0; i<namespaces.length; i+=2) {
        var fn = namespaces[i];
        var ns = namespaces[i+1];
        fn.apply(ns);
    }
	   if (AccessibilityExtension.LIB.accessext_initialize) AccessibilityExtension.LIB.accessext_initialize();
};

// Clean up
this.shutdown = function() {
    window.removeEventListener("load", AccessibilityExtension.initialize, false);
    window.removeEventListener("unload", AccessibilityExtension.shutdown, false);
};

// Register handlers to maintain extension life cycle.
window.addEventListener("load", AccessibilityExtension.initialize, false);
window.addEventListener("unload", AccessibilityExtension.shutdown, false);

}).apply(AccessibilityExtension);

AccessibilityExtension.ns(function() { 
	var mydoc;
	var thewindow;
		
	var treebox = null;
	var treebox_main = null;		//
	var treebox_watch = null;		//WATCH listview for listofdhtml

	var dataarray = null;			// treebox
	var primaryarray = null; 		// treebox_main
	var watcharray = null;			// treebox_watch
	var sortProperty;
	
	var AE = AccessibilityExtension.ns;  
	AE.accessext_openWindows = Array();
	AE.accessibilityIssuesDialog = null; //set when an issuesummary window is open
	AE.sortColumn = "list-header-order";
	AE.sortColumn_main = "list-header-main-order";
	AE.sortColumn_state = "list-header-order";
	AE.sortDirectionAscending = true;//use a toggle, so we can just negate
	AE.sortDirectionAscending_main = true;
	AE.sortDirectionAscending_state = true;

	
	//constants used with the forms dialog
	const source_label = 1, source_title = 2, source_value = 3, source_name = 4, source_none = 5, source_alt = 6, source_content = 7, source_default = 8;
	
	var wairoleProperties = null; // collection of wairoleObject objects

	AccessibilityExtension.Module = 
	{
		extend: function (l, r)
		{
			for (var n in r)
				l[n] = r[n];
		}
	};
	
	// available in other files if ...with (AccessibilityExtension.LIB)
	AccessibilityExtension.LIB = {
		extend: function (l, r)
		{
			for (var n in r)
				l[n] = r[n];
		},
		libFunctionCount: function (r, location) 
		{
			var i = 0;
			for (var n in r) i++;
			alert( location + ' libFunctionCount: ' + i);
		}
	};
});



